package Class.Advance.Static.ToolsClass;

import java.util.StringJoiner;

public class ArrayUtils {
    // 私有化构造方法，使得此类无法被当作对象来创建
    private ArrayUtils() {}

    public static String toString(int[] array) {
        StringJoiner joiner = new StringJoiner(", ", "[", "]");
        for(int i : array) {
            joiner.add(String.valueOf(i));
        }
        return joiner.toString();
    }

    public static int getSum(int[] array) {
        int sum = 0;
        for(int i : array) {
            sum += i;
        }
        return sum;
    }

    public static int getAverage(int[] array) {
        int sum = getSum(array);
        return (sum / array.length);
    }
}
